订阅通知

目的

请求订阅对模块或记录上执行操作的即时通知。

请求 URL

https://www.zohoapis.com.cn/crm/v2/actions/watch

请求方法

POST

范围

scope=ZohoCRM.notifications.{operation_type}

 
可能的操作类型
ALL - 完全访问通知数据
CREATE - 创建即时通知的订阅
WRITE - 编写即时通知订阅

输入 JSON 键

目的
token(可选)字符串(最大是50个字符)通过在通知URL主体中返回给定值,确保通知是从Zoho CRM发送的。通过使用此值,用户可以验证通知。
notify_url
(必填)
字符串要通知的URL (POST请求)。无论何时触发任何操作,通知都将通过此通知URL发送。
channel_id
(必填)
字符串(长)给定值在通知URL主体中发回,以确保通知是针对特定通道的。
channel_expiry字符串(ISO 日期时间)设定即时通知的有效期。从订阅时间开始最多只有一天。如果未指定或设置超过一天,则默认过期时间为一个小时。
events
(必填)
JSONArray
["{module_api_name}.{operation}",
"{module_api_name}.{operation}"]
例如: ["Leads.create","Sales_Orders.edit","Contacts.delete"]
可能的操作类型 - 创建,删除,编辑,全部
根据选定模块上的特定操作进行订阅。
 

获取关于URL的通知

在触发模块的任何订阅事件时,Zoho CRM通过通知URL向用户发送通知。

示例请求

在这个请求中,"@inputData.json" 包含了示例输入数据。


				curl "https://www.zohoapis.com.cn/crm/v2/actions/watch"
-X POST
-H "Authorization: Zoho-oauthtoken 1000.8cb99dxxxxxxxxxxxxx9be93.9b8xxxxxxxxxxxxxxxf"
-d "@inputData.json"			

示例输入


				{
    "watch": [
       {
            "channel_id": "1000000068001",
            "events": [
                "Solutions.create",
                "Price_Books.create",
                "Contacts.create",
                "Solutions.edit"
            ],
            "channel_expiry": "2018-02-02T10:30:00+05:30",
            "token": "TOKEN_FOR_VERIFICATION_OF_1000000068001",
            "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2"
        },
       {
            "channel_id": "1000000068002",
            "events": [
                "Deals.all"
            ],
            "channel_expiry": "2018-02-02T10:30:00+05:30",
            "token": "TOKEN_FOR_VERIFICATION_OF_1000000068002",
            "notify_url": """https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1&key2=val2&key3=val1"
        },
       {
            "channel_id": "1000000068003",
            "events": [
                "Cases.all"
            ],
            "channel_expiry": "2018-02-02T10:30:00+05:30",
            "token": "TOKEN_FOR_VERIFICATION_OF_1000000068003",
            "notify_url": "https://www.zoho.com/callback?authorization=Zoho-oauthtoken 1000.23dnsbbbh455jnn&key1=val1"
        }
    ]
}			

示例响应:对于新的订阅


				{
    "watch": [
       {
            "code": "SUCCESS",
            "details": {
                "events": [
                   {
                        "channel_expiry": "2018-02-02T10:30:00+05:30",
                        "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Solutions",
                        "resource_id": "1000000000091",
                        "resource_name": "Solutions",
                        "channel_id": "1000000068001"
                    },
                   {
                        "channel_expiry": "2018-02-02T10:30:00+05:30",
                        "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Contacts",
                        "resource_id": "1000000000045",
                        "resource_name": "Contacts",
                        "channel_id": "1000000068001"
                    },
                   {
                        "channel_expiry": "2018-02-02T10:30:00+05:30",
                        "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Price_Books",
                        "resource_id": "1000000000097",
                        "resource_name": "Price_Books",
                        "channel_id": "1000000068001"
                    }
                ]
            },
            "message": "Successfully subscribed for actions-watch of the given module",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "events": [
                   {
                        "channel_expiry": "2018-02-02T10:30:00+05:30",
                        "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Deals",
                        "resource_id": "1000000000047",
                        "resource_name": "Deals",
                        "channel_id": "1000000068002"
                    }
                ]
            },
            "message": "Successfully subscribed for actions-watch of the given module",
            "status": "success"
        },
       {
            "code": "SUCCESS",
            "details": {
                "events": [
                   {
                        "channel_expiry": "2018-02-02T10:30:00+05:30",
                        "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Cases",
                        "resource_id": "1000000000089",
                        "resource_name": "Cases",
                        "channel_id": "1000000068003"
                    }
                ]
            },
            "message": "Successfully subscribed for actions-watch of the given module",
            "status": "success"
        }
    ]
}			

示例请求:订阅主体


				{
    "query_params": {
        "key1": "val1",
        "ke2": "val2"
    },
    "resource_uri": "https://www.zohoapis.com.cn/crm/v2/Contacts",
    "module": "Contacts",
    "ids": [
        "1000000033163"
    ],
    "operation": "update",
    "channel_id": "1000000000045",
    "token": "TOKEN_FOR_VERIFICATION_OF_1000000000045"
}